#include <iostream>
#include <string>
#include <stack>

bool is_valid_brackets(const std::string& sequence) {
    std::stack<char> stack;
    std::string opening_brackets = "([{<";
    std::string closing_brackets = ")]}>";
    for (char bracket : sequence) {
        if (opening_brackets.find(bracket) != std::string::npos) {
            stack.push(bracket);
        } else if (closing_brackets.find(bracket) != std::string::npos) {
            if (stack.empty()) {
                return false;
            }
            char opening_bracket = stack.top();
            stack.pop();
            if (opening_brackets.find(opening_bracket) != closing_brackets.find(bracket)) {
                return false;
            }
        }
    }
    return stack.empty();
}

int main() {
    std::string input_sequence;
    std::cout << "Введите последовательность скобок: ";
    std::cin >> input_sequence;
    bool result = is_valid_brackets(input_sequence);
    std::cout << (result ? "true" : "false") << std::endl;
    return 0;
}
